<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Usage</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Boost.Sort">
<link rel="up" href="../pdqsort.html" title="2.2.- pdqsort">
<link rel="prev" href="../pdqsort.html" title="2.2.- pdqsort">
<link rel="next" href="pdqsort_benchmark.html" title="Benchmark">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../pdqsort.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../pdqsort.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="pdqsort_benchmark.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="sort.single_thread.pdqsort.pdqsort_usage"></a><a class="link" href="pdqsort_usage.html" title="Usage">Usage</a>
</h4></div></div></div>
<p>
          Pattern-defeating quicksort is available through two calls, <code class="literal"><code class="computeroutput">pdqsort</code></code> and <code class="literal"><code class="computeroutput">pdqsort_branchless</code></code>.
          Both have identical guarantees, behavior and overloads as <a href="http://en.cppreference.com/w/cpp/algorithm/sort" target="_top">std::sort</a>,
          with the exception of the C++17 parallel execution policy argument. Thus
          you can simply replace a call to <a href="http://en.cppreference.com/w/cpp/algorithm/sort" target="_top">std::sort</a>
          with <code class="literal"><code class="computeroutput">pdqsort</code></code>,
          it is simply a faster implementation. It is almost always appropriate to
          simply call <code class="literal"><code class="computeroutput">pdqsort</code></code>
          and ignore <code class="literal"><code class="computeroutput">pdqsort_branchless</code></code>.
        </p>
<p>
          <code class="literal"><code class="computeroutput">pdqsort_branchless</code></code>
          runs significantly faster than <code class="literal"><code class="computeroutput">pdqsort</code></code>
          for comparison functions that are branchless (for an explanation why see
          'The Average Case' below), such as simple integer or float comparison,
          and slightly slower when the comparison function contains branches. When
          using an arithmetic type and a default comparison function (<a href="http://en.cppreference.com/w/cpp/utility/functional/less" target="_top">std::less</a>
          or <a href="http://en.cppreference.com/w/cpp/utility/functional/greater" target="_top">std::greater</a>)
          <code class="literal"><code class="computeroutput">pdqsort</code></code>
          automatically delegates to <code class="literal"><code class="computeroutput">pdqsort_branchless</code></code>.
          If you know that your custom comparison function is branchless and wish
          to make use of this speedup call <code class="literal"><code class="computeroutput">pdqsort_branchless</code></code>
          explicitly.
        </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2014-2017 Steven
      Ross, Francisco Tapia, Orson Peters<p>
        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
        Software License, Version 1.0</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../pdqsort.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../pdqsort.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="pdqsort_benchmark.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
